<?php



/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
 
class Gmap_Widget_ListFeaturedController extends Engine_Content_Widget_Abstract
{

  public function indexAction()
  {
  	
    // Don't render this if not authorized
    $viewer = Engine_Api::_()->user()->getViewer();

    $this->view->titlelength = $this->_getParam('titlelength', 48);
    $this->view->descriptionlength = $this->_getParam('descriptionlength', 160);
    $this->view->items_per_page = $max = $this->_getParam('max', 1);
    $this->view->show_details = $this->_getParam('details', 0);
    $this->view->show_photo = $this->_getParam('photo', 1);
    
    if (!$this->view->items_per_page)
    {
      return $this->setNoRender();
    }    
    
    $this->view->paginator = $paginator = Engine_Api::_()->gmap()->getMappableGmapsPaginator(array(
      'order' => 'random',
      'featured' => 1,
      'limit' => $this->view->items_per_page,
    ));

      // Do not render if nothing to show
    if( $paginator->getTotalItemCount() <= 0 ) {
      return $this->setNoRender();
    }
  }

}